package com.hfb.mashibing.alip8.spring.controller;

import com.hfb.mashibing.alip8.spring.entity.Person;
import com.hfb.mashibing.alip8.spring.mapper.PersonMapper;
import java.util.List;
import javax.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@Slf4j
public class MyController {

    @Value("${random.int(10)}")
    private int random;
    @Autowired
    private HttpSession session;
    @Autowired
    private PersonMapper personMapper;

    @RequestMapping(value = "hello")
    public String hello(){
        log.debug("hello->()");

        List<Person> all = personMapper.getAll();

        session.setAttribute("user.name", "hfb"+random);

        return "hello";
    }

}
